package com.zhongbo.java.websocket.vo;

import lombok.Data;


@Data
public class RestResultVo<T> {

    /**
     * 项目定义的状态码, 这里定义 0 表示成功,其他表示其他的错误代码;
     */
    private int status;

    /**
     * 错误消息
     */
    private String message;

    /**
     * 响应内容
     */
    private T data;

    public static <T> RestResultVo<T> success() {
        RestResultVo<T> resultVo = new RestResultVo<>();
        resultVo.setStatus(0);
        return resultVo;
    }

    public static <T> RestResultVo<T> ok(T data) {
        RestResultVo<T> resultVo = new RestResultVo<>();
        resultVo.setStatus(0);
        resultVo.setData(data);
        return resultVo;
    }

    public static <T> RestResultVo<T> failed(String msg) {
        RestResultVo<T> resultVo = new RestResultVo<>();
        resultVo.setStatus(-1);
        resultVo.setMessage(msg);
        return resultVo;
    }

    public static <T> RestResultVo<T> failed() {
        RestResultVo<T> resultVo = new RestResultVo<>();
        resultVo.setStatus(-1);
        return resultVo;
    }
}
